home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / GSDMO_03.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-02  |  3KB  |  97 lines

  1. program GSDMO_03;
  2. {------------------------------------------------------------------------------
  3.                           DBase File Formated Lister
  4.  
  5.        Copyright (c)  Richard F. Griffin
  6.  
  7.        20 January 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        This program demonstrates how dBase files may be listed using
  14.        different field type formats.
  15.  
  16.        If the GSDMO_01.DBF file does not exist, the program will display a
  17.        a message that the file was not found and to run GSDMO_01 to make
  18.        the file.
  19.  
  20.        The program opens a dBase file and proceeds to list selected fields
  21.        from each record.
  22.  
  23.        The NumberGet, DateGet, and StringGet commands are shown in the
  24.        example.  This is intended to contrast them with the basic FieldGet
  25.        command used to get the field image directly from disk.
  26.  
  27.        The NumberGet Procedure returns the actual numeric value in the field.
  28.        This should be used on Number fields only as it returns a real value.
  29.  
  30.        The DateGet Function is used to retrieve a longint Julian Date from
  31.        the date field.  See GSOB_DTE.PAS for an explanation of Julian Dates.
  32.        Several other date handling routines are shown, such as SetDate(),
  33.        SetCenturyOn, and DTOC()
  34.  
  35.        The StringGet Function returns the trimmed string.
  36.  
  37.        DTOC is used to display a 'viewable' date from the longint Julian
  38.        Date value retrieved by DateGet.
  39.  
  40.        New procedures/functions introduced are:
  41.  
  42.                  DateGet
  43.                  DTOC
  44.                  NumberGet
  45.                  SetCenturyOn
  46.                  SetDateStyle
  47.                  StringGet
  48.  
  49. -------------------------------------------------------------------------------}
  50.  
  51. uses
  52.    GSOB_Var,
  53.    GSOBShel,
  54.    {$IFDEF WINDOWS}
  55.       WinCRT,
  56.       WinDOS;
  57.    {$ELSE}
  58.       CRT,
  59.       DOS;
  60.    {$ENDIF}
  61.  
  62. var
  63.    rnum    : FloatNum;
  64.    dnum    : longint;
  65. begin
  66.    ClrScr;
  67.    if not FileExist('GSDMO_01.DBF') then
  68.    begin
  69.       writeln('File GSDMO_01.DBF not found.  Run GSDMO_01 to create.');
  70.       halt;
  71.    end;
  72.                        {The 'Real' example starts here}
  73.  
  74.    SetDateStyle(USA);           {Sets the Date type to mm-dd-yy}
  75.    SetCenturyOn;                {Gives full century on date display (YYYY)}
  76.                                 {default is false for YY only.}
  77.    Select(1);
  78.    Use('GSDMO_01');
  79.    GoTop;
  80.    while not dEOF do
  81.    begin
  82.       rnum := NumberGet('PAYMENT');  {use real number for math later}
  83.       dnum := DateGet('BIRTHDATE');  {use for date conversion later}
  84.  
  85.       writeln(StringGet('LASTNAME'),', ',
  86.                                      {Get field without trailing spaces}
  87.               StringGet('FIRSTNAME'),'  ',
  88.               DTOC(dnum),' [',
  89.               StringGet('PAYMENT'),']',
  90.               rnum/12:8:2);          {Compute and list PAYMENT / 12}
  91.       Skip(1);
  92.    end;
  93.    CloseDataBases;
  94.    write('Press any Key to continue:');
  95.    repeat until KeyPressed;
  96. end.
  97.